package com.andrew.dao;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import com.andrew.entity.Book;
import com.andrew.entity.CartDetail;


public interface BookDao {
	/**
	 * 分页查询书本
	 * @param 搜索条件，当前是第几页
	 * @return 一页的书本集合
	 * @throws SQLException
	 */
	public abstract List<Book> findBooksByPage(String queryTerm,int currentPage) throws SQLException;
	
	/**
	 * 查询所有书本
	 * @param 搜索条件
	 * @return  所有书本集合
	 * @throws SQLException
	 */
	public abstract List<Book> findAllExistBooks(String queryTerm) throws SQLException;
	
	/**
	 * 查询一共多少本书
	 * @param 搜索条件
	 * @return	一共多少本书
	 * @throws SQLException
	 */
	public abstract long getExistBooksCount(String queryTerm) throws SQLException;
	/**
	 * 通过书本id查询书本
	 * @param bookId
	 * @return
	 * @throws SQLException
	 */
	public Book queryBookbyBookId(int bookId)throws SQLException;
	
	public int addBook(Book book)throws SQLException;
	
	/**
	 * 改变库存
	 * @param bookId
	 * @param quantity
	 * @throws SQLException
	 */
	public abstract int changeStocks(int bookId,int quantity) throws SQLException;
	/***
	 * 查看所有图书
	 * @return
	 * @throws SQLException
	 */
	public List<Book> queryAllBook()throws SQLException;
	/***
	 * 修改图书的照片
	 * @param bookId
	 * @param picture
	 * @return
	 * @throws SQLException
	 */
	public int updatePictureForBook(int bookId,String picture)throws SQLException;
	
	/***
	 * 修改图书的所有信息 除了照片
	 * @param book
	 * @return
	 * @throws SQLException
	 */
	public int updateBookAll(Book book)throws SQLException;
}
